﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Transformer.iHunter.Plugins.Email
{
    class EmailChannelProvider : IChannelProvider
    {
        DataSet dataSet;

        #region IChannelProvider Members

        public System.Windows.Forms.UserControl GetChannelConfigureEditor()
        {
            return new EmailConfigControl();
        }

        public System.Windows.Forms.UserControl[] GetNewChannelWizardPages()
        {
            return new System.Windows.Forms.UserControl[]{
                new EmailConfigControl()
            };
        }


        public System.Xml.XPath.XPathNavigator ContextualCommands
        {
            get { return null; }
        }

        #endregion

        #region IPlugin Members

        public Guid Guid
        {
            get
            {
                return new Guid("14872CC8-D96F-4061-8C98-312DF14790D7");
            }
        }

        public void Initialize(IPluginClient client)
        {
            dataSet = client.GetPluginDatabase();
        }

        public System.Windows.Forms.UserControl GetPluginConfigureEditor()
        {
            return null;
        }

        public event PluginErrorEventHandler ErrorOccur;

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            //do nothing
        }

        #endregion

        #region IChannelProvider Members

        public IChannel CreateChannelInstance(ChannelInfo info)
        {
            try
            {

                EmailChannel channel = new EmailChannel(info.Settings, dataSet,info.Guid.ToString());


                return channel;

            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region IPlugin 成员


        public string Name
        {
            get { return "Email Box"; }
        }

        public string Description
        {
            get { return "A email box provider supporting POP3, IMAP4 and SMTP"; }
        }

        #endregion
        public Guid NewMesssageEditorGuid
        {
            get { return Transformer.iHunter.UI.HtmlEditorProvider.Guid; }
        }
    }
}
